package org.alanlau.alibaba.controller;

import org.alanlau.alibaba.context.InfoContextHolder;
import org.alanlau.alibaba.feign.TestClient;
import org.alanlau.alibaba.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liukun
 * @version 1.0
 * @date 2020/11/27 11:01
 */
@RestController
public class TestController {
    @Autowired
    private TestService testService;

    @Autowired
    private TestClient testClient;

    @GetMapping("/hello")
    public String sayHello() {
        return testService.sayHello();
    }

    @GetMapping("/test")
    public String test() {
        return "test";
    }

    @GetMapping("/feign-hello")
    public String feignHello() {
        System.out.println(InfoContextHolder.getMsg());
        InfoContextHolder.setMsg("测试啊");
        return testClient.sayHello();
    }

    @GetMapping("feign-hello2")
    public String feignHello2() {
        return testClient.sayHello2();
    }
}
